/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Container with responsive height */
.container {
    width: 100%;
    height: 100vh; /* Default full viewport height */
    max-width: 800px;
    margin: 0 auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

/* Iframe detection and height adjustment */
@media screen and (max-height: 500px) {
    .container {
        height: 450px; /* Iframe height */
    }
}

@media screen and (min-height: 501px) {
    .container {
        height: 90vh; /* Browser tab height */
    }
}

/* Welcome panel styling */
.welcome-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.welcome-panel:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.emoji-header {
    font-size: 2.5em;
    margin-bottom: 10px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.welcome-text {
    font-size: 1.2em;
    font-weight: 600;
    color: #4a5568;
    margin: 0;
}

/* Input section styling */
.input-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#textInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
    transition: all 0.3s ease;
    background: #f8fafc;
}

#textInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

.analyze-btn {
    width: 100%;
    padding: 15px 20px;
    margin-top: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.analyze-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.analyze-btn:active {
    transform: translateY(0);
}

/* Results section styling */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    overflow-y: auto;
}

.analysis-block {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.analysis-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.block-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Emotion stages visualization */
.emotion-stages {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.emotion-tag {
    background: linear-gradient(135deg, #ffeaa7 0%, #fab1a0 100%);
    color: #2d3748;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.emotion-tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.arrow {
    font-size: 1.2em;
    color: #667eea;
    font-weight: bold;
}

/* Curve visualization */
.curve-container {
    display: flex;
    justify-content: center;
    margin: 15px 0;
    background: #f8fafc;
    border-radius: 10px;
    padding: 15px;
}

#emotionCurve {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    max-width: 100%;
    height: auto;
}

.curve-description {
    background: #f0f4f8;
    padding: 15px;
    border-radius: 10px;
    font-style: italic;
    color: #4a5568;
    border-left: 4px solid #667eea;
    margin-top: 10px;
}

/* Turning points and other content */
.turning-points, .reflection, .encouragement {
    background: #f8fafc;
    padding: 15px;
    border-radius: 10px;
    color: #4a5568;
    line-height: 1.8;
}

/* Naming section */
.naming-section {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#curveNameInput {
    flex: 1;
    min-width: 200px;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

#curveNameInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.name-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    min-height: 44px;
}

.name-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.3);
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 250px;
    word-wrap: break-word;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.tooltip.show {
    opacity: 1;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 8px;
        gap: 12px;
    }
    
    .welcome-panel, .input-section, .analysis-block {
        padding: 15px;
    }
    
    .emoji-header {
        font-size: 2em;
    }
    
    .welcome-text {
        font-size: 1.1em;
    }
    
    #textInput {
        font-size: 16px; /* Prevent zoom on iOS */
        min-height: 80px;
    }
    
    .emotion-stages {
        justify-content: center;
    }
    
    .naming-section {
        flex-direction: column;
    }
    
    #curveNameInput {
        min-width: 100%;
    }
}

/* Touch target optimization */
@media (hover: none) and (pointer: coarse) {
    .analyze-btn, .name-btn {
        min-height: 48px;
        font-size: 16px;
    }
    
    .emotion-tag {
        min-height: 36px;
        padding: 10px 15px;
    }
    
    #textInput, #curveNameInput {
        min-height: 48px;
        font-size: 16px;
    }
}